package net.hn.hnms.sys.common.feign;

import cn.dev33.satoken.id.SaIdUtil;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;

/**
 * 当启用网关转发鉴权的时候，Feign调用需要配置IdToken认证
 *
 * @author jiangmf
 * @see sys.common.security.config.SecurityConfiguration.getSaServletFilter()
 */
@Component
public class FeignInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate requestTemplate) {
        requestTemplate.header(SaIdUtil.ID_TOKEN, SaIdUtil.getToken());
    }
}
